package com.gee.spring.boot.starter.opengemini.core.convertor;

import java.time.LocalDateTime;

import static com.gee.spring.boot.starter.opengemini.core.util.TimeUtil.nanosToTime;
import static com.gee.spring.boot.starter.opengemini.core.util.TimeUtil.timeToNanos;


/**
 * @author gepengjun
 * @since 2024/4/24 14:05
 */
public class LocalDateTimeNanosConvertor implements Convertor<LocalDateTime, String> {

    @Override
    public LocalDateTime toJavaValue(String nanos) {
        return nanosToTime(Long.parseLong(nanos));
    }

    @Override
    public String toSaveValue(LocalDateTime localDateTime) {
        return String.valueOf(timeToNanos(localDateTime));
    }
}
